package com.bocsoft.dbsp.base.entity.message;

//import com.bocsoft.dbsp.base.entity.message.RespErrorBody;


public class MyJavaRules34 {

    public M54075Resp addOrUpdateRelatedPerson(M54075Req m54075Req) {
        log.info("预约开户干系人新增或更新 BookManagerServiceImpl.addOrUpdateRelatedPerson start: " + m54075Req);
        M54075Resp aaa3 = getMyResponse();
        MyJavaRules34 myJavaRules34 = new MyJavaRules34();
        myJavaRules34.anotherValidExample();
        final String telno = m54075Req.getHeader().getTelno();
        final String bookNo = m54075Req.getBookNo();
        final String custRoles = m54075Req.getCustRoles();
        M54075Resp response = new M54075Resp();
        if (MiscUtil.isNullOrEmpty(bookNo)) {
            throw new CsarBusinessException(ErrMsg.E_BOOK_NO_NOT_EMPTY);
        }
        if(StringUtils.isBlank(custRoles)) {
            throw new CsarBusinessException(ErrMsg.CUST_ROLES_NOT_EMPTY);
        }
        String relatedPersonNo = m54075Req.getRelatedPersonNo();
        // 检查预约信息是否存在,并检查预约数据信息

        BookJobCurInfoQuery bookJobQueryCurInfo = lcmaBookManagerMapper.bookJobQueryCurInfo(bookNo);
        if (MiscUtil.isNullOrEmpty(bookJobQueryCurInfo)) {
            throw new CsarBusinessException(ErrMsg.BOOK_NO_HANDLE_TEL_NO_EMPTY);
        }
        final String handleTelNo = bookJobQueryCurInfo.getHandleTelNo();
        // final String inner_flw_sts = MapUtils.getString(retMap, "inner_flw_sts");
        if (StringUtils.isBlank(handleTelNo)) {
            throw new CsarBusinessException(ErrMsg.BOOK_NO_HANDLE_TEL_NO_EMPTY);
        }
        if (!handleTelNo.equals(telno)) {
            throw new CsarBusinessException(ErrMsg.BOOK_NO_HANDLE_TEL_NO_ERROR);
        }
        // 根据related_person_no是新增还是修改干系人
        if (StringUtils.isNotBlank(relatedPersonNo)) {
            relatedPersonNo = updateRelatedPerson(m54075Req);
        } else {
            Date bookNoDate = new Date();
            String txnDate = new SimpleDateFormat(Constants.DATE_FORMAT2).format(bookNoDate);
            RelatedPersonNoParamEntity  entity = new RelatedPersonNoParamEntity();
            lcmaBookRelatedPersonInfoMapper.getRelatedPersonNoSeqVal(entity);
            if(entity.getRelatedPersonNo()< 10000000){
                relatedPersonNo = txnDate + MiscUtil.StrForNum(MiscUtil.object2String(entity.getRelatedPersonNo()),7) ;
            }
            else {
                String  personNo =   MiscUtil.object2String(entity.getRelatedPersonNo());
                relatedPersonNo = txnDate + personNo.substring(personNo.length()-7,personNo.length());
            }
            m54075Req.setRelatedPersonNo(relatedPersonNo);
            relatedPersonNo = addRelatedPerson(m54075Req);
        }

        response.setBookNo(bookNo);// Noncompliant {{接口返回值使用前应做非空检查。}}
        response.setRelatedPersonNo(relatedPersonNo);
        return response;
    }

}

class RespErrorBody {}

class MyResponse extends RespErrorBody{}

class BaseRespBody extends RespErrorBody{}

class M54075Resp extends BaseRespBody{}

class Response {}